<?php


// no direct access
defined('_JEXEC') or die('Restricted access');


jimport('joomla.application.component.controller');


class ContactFormController extends JController
{
	function __construct()
	{
		parent::__construct();

		$this->registerTask('send', 'send');
		$this->registerTask('success', 'success');
	}

    function display()
    {
		$model = $this->getModel('ContactForm');
		$view = $this->getView('ContactForm', 'html');
		$view->assign('model', $model);
		$view->display();
    }

	function send()
	{
		$model = $this->getModel('ContactForm');
		if ($model->send())
			$this->setRedirect(JRoute::_('index.php?option=com_contactform&task=success', false));
		else
		{
			$view = $this->getView('ContactForm', 'html');
			$view->assign('message', $model->getError());
			$view->assign('model', $model);
			$view->display();
		}
	}

	function success()
	{
		$view = $this->getView('ContactForm', 'html');
		$view->display('success');
	}
}


?>
